
if exists(select name from sysobjects where name = 'sp_GroupNewsCreateEdit')
	drop proc sp_GroupNewsCreateEdit
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_GroupNewsCreateEdit.sql
*/


-- =============================================
-- Author		: HP
-- Create date	: 2014-03-22
-- =============================================

CREATE PROCEDURE sp_GroupNewsCreateEdit
			
	@Id         		INT,
	@Name       		NVARCHAR(256)= null,
	@Tag        		NVARCHAR(256)= null,
	@Title      		NVARCHAR(256)= null,
	@Description		NVARCHAR(256)= null,
	@Keyword    		NVARCHAR(512)= null,
	@Ord        		INT,
	@Priority   		INT,
	@Index      		INT,
	@Active     		INT,
	@Lang       		VARCHAR(5)=null,
	@ParentId   		INT
	
AS
BEGIN
    IF(@Id=0)
        BEGIN
        	INSERT INTO GroupNews
        	(
		[Name],
		[Tag],
		[Title],
		[Description],
		[Keyword],
		[Ord],
		[Priority],
		[Index],
		[Active],
		[Lang],
		[ParentId]
        	) 
        	VALUES 
        	(
		@Name,
		@Tag,
		@Title,
		@Description,
		@Keyword,
		@Ord,
		@Priority,
		@Index,
		@Active,
		@Lang,
		@ParentId
        	)
        END
     ELSE
        BEGIN
            UPDATE GroupNews     
            SET
		[Name]        = @Name,
		[Tag]         = @Tag,
		[Title]       = @Title,
		[Description] = @Description,
		[Keyword]     = @Keyword,
		[Ord]         = @Ord,
		[Priority]    = @Priority,
		[Index]       = @Index,
		[Active]      = @Active,
		[Lang]        = @Lang,
		[ParentId]    = @ParentId
	WHERE
		    [Id]       = @Id;
        END
END
GO


